<?php
include "../../fun.php";
isLogin();
$db=conndb();
$username=$_POST["username"]; //获取索引
$password=base64_encode($_POST["password"]);
$realname=$_POST["realname"];
$time=time();
$id=isset($_POST["id"])?$_POST["id"]:'';
if ($id) {
    $sql="update user set username='{$username}',password='{$password}',realname='{$realname}',time='{$time}' where id='{$id}'";
} else {
    $sql="insert into user (username,password,realname,time) values ('{$username}','{$password}','{$realname}','{$time}')";
}
$db->exec($sql);
$data=["code"=>0,"msg"=>"操作成功"];
echo json_encode($data, JSON_UNESCAPED_UNICODE);
